//
//  EmptyView.m
//  YiGuo
//
//  Created by sam lau on 17/4/24.
//  Copyright © 2017年 sam lau. All rights reserved.
//

#import "EmptyView.h"

@interface EmptyView()



@end

@implementation EmptyView



#pragma mark - 单利
+(instancetype)shareInstance{
    static dispatch_once_t onceToken;
    static  EmptyView *_shareInstance = nil;
    dispatch_once(&onceToken, ^{
        _shareInstance = [[self alloc] init];
    });
    return _shareInstance;
}

-(instancetype)initWithFrame:(CGRect)frame{
    if(self == [super initWithFrame:frame]){
        
        
        self.backgroundColor = [UIColor whiteColor];
        UIImageView *imageView = [UIImageView new];
        [self addSubview:imageView];
        self.imageView = imageView;
        imageView.image = [UIImage imageNamed:@"noData"];

        
        UILabel *label = [UILabel new];
        [self addSubview:label];
        self.label = label;
        label.text = [NSString stringWithFormat:@"没有数据"];
        label.font = CHINESE_PingFangRegular(18);
        label.textColor = CellColor2;
        label.textAlignment = NSTextAlignmentCenter;

    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.imageView.sam_size = CGSizeMake(120, 120);
    self.imageView.center = CGPointMake(self.sam_centerX, self.sam_centerY - 50);
    self.label.sam_size = CGSizeMake(200, 40);
    self.label.center = CGPointMake(self.sam_centerX, self.imageView.sam_maxY + 30);
    
}

-(void)setIfProblem:(BOOL)ifProblem{
    if (ifProblem) {
        self.imageView.image = [UIImage imageNamed:@"load"];
        self.label.text =  [NSString stringWithFormat:@"网络问题"];
    }else{
         self.imageView.image = [UIImage imageNamed:@"noData"];
        self.label.text =  [NSString stringWithFormat:@"没有数据"];
    }
}

-(void)setIfShow:(BOOL)ifShow{
    if (ifShow) {
        self.hidden = NO;
    }else{
        self.hidden = YES;
    }
}

@end
